<template>
  <div class="ad-form">
    <el-form size="mini" inline label-position="right" label-width="auto" ref="form" :model="form" v-loading="loading" :disabled="isDisableForm">
      <el-form-item prop="userId" :rules="[{required: true, message: '请选择'}]">
        <ad-select placeholder="请选择业务员" v-model="form.userId" :options="sellerData" size="medium"
                 :config="{optionKey: 'nickName', optionValue: 'id'}"/>
      </el-form-item>
    </el-form>
    <div class="op">
      <el-button type="primary" :loading="saving" @click="save">确 定</el-button>
      <el-button type="primary" plain @click="$emit('update:visible', false)">取 消</el-button>
    </div>
  </div>
</template>

<script>
import AdSelect from '@/components/AdSelect'
import adForm from '@/mixins/adForm'
import { assignSeller as add, getSellerList } from '@/api/order/assign'

export default {
  components: {AdSelect},
  mixins: [adForm({add})],
  data() {
    return {
      sellerData: [],
      form: {
        appOrderIds: this.$attrs.rows.map(row => row.id),
        userId: ''
      }
    }
  },
  created() {
    getSellerList().then(res => this.sellerData = res.data)
  }
}
</script>

<style lang="scss" scoped>
.ad-form { display: flex; height: 140px; flex-direction: column;
  .el-form { display: flex; flex: 1; padding: 0 50px; align-items: center; }
  .op { margin-top: 0; }}
</style>